package utils
{
	import flash.utils.getDefinitionByName;
	
	import common.entities.ModuleVO;
	
	import components.base.BaseContainer;
	
	public class ModuleUtil
	{
		
		/**
		 * 模组加载通用方法
		 */
		public static function loadModule(p_moduleVO:ModuleVO):BaseContainer
		{
			if(!p_moduleVO)return null;
			var arr:Array = p_moduleVO.moduleURL.split("?");
			var path:String = String(arr[0]).split("/").join(".");
			var clazz:Object = getDefinitionByName(path);
			var module:BaseContainer = new clazz;
			module.moduleVO = p_moduleVO;
			if(arr.length > 1){
				var paramStr:String = arr[1];
				var paramArr:Array = paramStr.split("&");
				var params:Array = [];
				for(var i:int = 0;i < paramArr.length;i++){
					var keys:Array = String(paramArr[i]).split("=");
					if(keys.length > 1)
						params[keys[0]] = keys[1];
				}
				module.parameters = params;
			}
			return module;
		}
	}
}